<!doctype html>
<html style='font-size:13px !important'>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>Maven笔记</title><style type='text/css'>html {overflow-x: initial !important;}:root { --bg-color:#ffffff; --text-color:#333333; --select-text-bg-color:#B5D6FC; --select-text-font-color:auto; --monospace:"Lucida Console",Consolas,"Courier",monospace; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; tab-size: 4; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; overflow-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 40px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
@media screen and (max-width: 500px) {
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  #write { padding-left: 20px; padding-right: 20px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { color: inherit; font: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 2; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px !important; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror-linenumber { user-select: none; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
  body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; }
  #write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 32px; padding-right: 32px; padding-bottom: 0px; break-after: avoid; }
  .typora-export #write::after { height: 0px; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); }
code { text-align: left; vertical-align: initial; }
a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.html-for-mac .inline-math-svg .MathJax_SVG { vertical-align: 0.2px; }
.md-math-block .MathJax_SVG_Display { text-align: center; margin: 0px; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; overflow-y: hidden; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: var(--monospace); }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none 0s ease 0s; }
.MathJax_SVG_Display svg { vertical-align: middle !important; margin-bottom: 0px !important; margin-top: 0px !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="mermaid"] svg, [lang="flow"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }


.CodeMirror { height: auto; }
.CodeMirror.cm-s-inner { background: inherit; }
.CodeMirror-scroll { overflow: auto hidden; z-index: 3; }
.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background: inherit; white-space: nowrap; }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-property { color: rgb(0, 0, 0); }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: 700; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: red; }
.cm-invalidchar { color: red; }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background: inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background: inherit; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: hidden; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: 0px 0px !important; border: none !important; }
.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; background: 0px 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; overflow-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }
.CodeMirror-wrap pre { overflow-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
@media print {
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}


:root { --side-bar-bg-color: #fff; --control-text-color: #777; }
html { font-size: 14px; }
body { font-family: "Courier New"; color: rgb(52, 73, 94); -webkit-font-smoothing: antialiased; line-height: 1.6rem; letter-spacing: 0px; margin: 0px; overflow-x: hidden; }
#write { max-width: 95%; margin: 0px auto; padding: 20px 30px 30px; }
#write p { line-height: 1.6rem; word-spacing: 0.05rem; }
#write ol li { text-indent: 0.5rem; }
#write > ul:first-child, #write > ol:first-child { margin-top: 30px; }
body > :first-child { margin-top: 0px !important; }
body > :last-child { margin-bottom: 0px !important; }
a { color: rgb(66, 185, 131); font-weight: 600; padding: 0px 2px; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; cursor: text; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; }
h1 tt, h1 code { font-size: inherit !important; }
h2 tt, h2 code { font-size: inherit !important; }
h3 tt, h3 code { font-size: inherit !important; }
h4 tt, h4 code { font-size: inherit !important; }
h5 tt, h5 code { font-size: inherit !important; }
h6 tt, h6 code { font-size: inherit !important; }
h2 a, h3 a { color: rgb(52, 73, 94); }
h1 { padding-bottom: 0.4rem; font-size: 2.2rem; line-height: 1.3; }
h2 { font-size: 1.75rem; line-height: 1.225; margin: 35px 0px 15px; padding-bottom: 0.5em; border-bottom: 1px solid rgb(221, 221, 221); }
h3 { font-size: 1.4rem; line-height: 1.43; margin: 20px 0px 7px; }
h4 { font-size: 1.2rem; }
h5 { font-size: 1rem; }
h6 { font-size: 1rem; color: rgb(119, 119, 119); }
p, blockquote, ul, ol, dl, table { margin: 0.8em 0px; }
li > ol, li > ul { margin: 0px; }
hr { height: 2px; padding: 0px; margin: 16px 0px; background-color: rgb(231, 231, 231); border: 0px none; overflow: hidden; box-sizing: content-box; }
body > h2:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child + h2 { margin-top: 0px; padding-top: 0px; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child { margin-top: 0px; padding-top: 0px; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 { margin-top: 0px; padding-top: 0px; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { margin-top: 0px; }
li p.first { display: inline-block; }
ul, ol { padding-left: 30px; }
ul:first-child, ol:first-child { margin-top: 0px; }
ul:last-child, ol:last-child { margin-bottom: 0px; }
blockquote { border-left: 4px solid rgb(66, 185, 131); padding: 10px 15px; color: rgb(119, 119, 119); background-color: rgba(66, 185, 131, 0.1); }
table { padding: 0px; word-break: initial; }
table tr { border-top: 1px solid rgb(223, 226, 229); margin: 0px; padding: 0px; }
table tr:nth-child(2n), thead { background-color: rgb(250, 250, 250); }
table tr th { font-weight: bold; border-width: 1px 1px 0px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-top-color: rgb(223, 226, 229); border-right-color: rgb(223, 226, 229); border-left-color: rgb(223, 226, 229); border-image: initial; border-bottom-style: initial; border-bottom-color: initial; text-align: left; margin: 0px; padding: 6px 13px; }
table tr td { border: 1px solid rgb(223, 226, 229); text-align: left; margin: 0px; padding: 6px 13px; }
table tr th:first-child, table tr td:first-child { margin-top: 0px; }
table tr th:last-child, table tr td:last-child { margin-bottom: 0px; }
#write strong { padding: 0px 1px; }
#write em { padding: 0px 5px 0px 2px; }
#write table thead th { background-color: rgb(242, 242, 242); }
#write .CodeMirror-gutters { border-right: none; }
#write .md-fences { border: 1px solid rgb(244, 244, 244); -webkit-font-smoothing: initial; line-height: 1.43rem; border-radius: 2px; font-size: 0.85rem; overflow-wrap: normal; margin: 0.8rem 0px !important; padding: 0.3rem 0px !important; background-color: rgb(248, 248, 248) !important; font-family: "Roboto Mono", "Source Sans Pro", Monaco, courier, monospace !important; }
#write .CodeMirror-wrap .CodeMirror-code pre { padding-left: 12px; }
#write code, tt { margin: 0px 2px; padding: 2px 4px; border-radius: 2px; font-size: 0.92rem; color: rgb(233, 105, 0); background-color: rgb(248, 248, 248); font-family: "Roboto Mono", "Source Sans Pro", Monaco, courier, monospace !important; }
#write .md-footnote { background-color: rgb(248, 248, 248); color: rgb(233, 105, 0); }
#write mark { background-color: rgb(235, 255, 235); border-radius: 2px; padding: 2px 4px; margin: 0px 2px; color: rgb(34, 34, 34); font-weight: 500; }
#write del { padding: 1px 2px; }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(34, 162, 201); }
.cm-s-inner .cm-string { color: rgb(34, 162, 201); }
.md-task-list-item > input { margin-left: -1.3em; }
@media print {
  html { font-size: 13px; }
  table, pre { break-inside: avoid; }
  pre { overflow-wrap: break-word; }
}
.md-fences { background-color: rgb(248, 248, 248); }
#write pre.md-meta-block { padding: 1rem; font-size: 85%; line-height: 1.45; background-color: rgb(247, 247, 247); border: 0px; border-radius: 3px; color: rgb(119, 119, 119); margin-top: 0px !important; }
.mathjax-block > .code-tooltip { bottom: 0.375rem; }
#write > h3.md-focus::before { left: -1.5625rem; top: 0.375rem; }
#write > h4.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h5.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h6.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
.md-image > .md-meta { border-radius: 3px; font-family: Consolas, "Liberation Mono", Courier, monospace; padding: 2px 0px 0px 4px; font-size: 0.9em; color: inherit; }
.md-tag { color: inherit; }
.md-toc { margin-top: 20px; padding-bottom: 20px; }
.sidebar-tabs { border-bottom: none; }
#typora-quick-open { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); }
#typora-quick-open-item { background-color: rgb(250, 250, 250); border-color: rgb(254, 254, 254) rgb(229, 229, 229) rgb(229, 229, 229) rgb(238, 238, 238); border-style: solid; border-width: 1px; }
#md-notification::before { top: 10px; }
.on-focus-mode blockquote { border-left-color: rgba(85, 85, 85, 0.12); }
header, .context-menu, .megamenu-content, footer { font-family: "Segoe UI", Arial, sans-serif; }
.file-node-content:hover .file-node-icon, .file-node-content:hover .file-node-open-state { visibility: visible; }
.mac-seamless-mode #typora-sidebar { background-color: var(--side-bar-bg-color); }
.md-lang { color: rgb(180, 101, 77); }
.html-for-mac .context-menu { --item-hover-bg-color: #E6F0FE; }


</style>
</head>
<body class='typora-export os-windows' >
<div  id='write'  class = 'is-node'><p>&nbsp;</p><div class='md-toc' mdtype='toc'><p class="md-toc-content"><span class="md-toc-item md-toc-h1" data-ref="n3"><a class="md-toc-inner" style="cursor: pointer;" href="#maven">maven</a></span><span class="md-toc-item md-toc-h2" data-ref="n4"><a class="md-toc-inner" style="cursor: pointer;" href="#%E5%BC%95%E8%A8%80">引言</a></span><span class="md-toc-item md-toc-h2" data-ref="n46"><a class="md-toc-inner" style="cursor: pointer;" href="#%E7%AC%AC%E4%B8%80%E4%B8%AAmaven%E9%A1%B9%E7%9B%AE(maven%E7%BC%96%E8%AF%91)">第一个Maven项目(maven编译)</a></span><span class="md-toc-item md-toc-h3" data-ref="n47"><a class="md-toc-inner" style="cursor: pointer;" href="#1.-maven%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%BC%96%E5%86%99">1. maven配置文件的编写</a></span><span class="md-toc-item md-toc-h3" data-ref="n55"><a class="md-toc-inner" style="cursor: pointer;" href="#2.-%E7%BA%A6%E5%AE%9A%E7%9A%84%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84">2. 约定的项目结构</a></span><span class="md-toc-item md-toc-h3" data-ref="n58"><a class="md-toc-inner" style="cursor: pointer;" href="#3.-%E5%87%86%E5%A4%87%E4%BB%A3%E7%A0%81">3. 准备代码</a></span><span class="md-toc-item md-toc-h3" data-ref="n60"><a class="md-toc-inner" style="cursor: pointer;" href="#3.-%E6%89%A7%E8%A1%8Cmaven%E5%91%BD%E4%BB%A4">3. 执行maven命令</a></span><span class="md-toc-item md-toc-h2" data-ref="n67"><a class="md-toc-inner" style="cursor: pointer;" href="#maven%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5">Maven核心概念</a></span><span class="md-toc-item md-toc-h3" data-ref="n68"><a class="md-toc-inner" style="cursor: pointer;" href="#pom">POM</a></span><span class="md-toc-item md-toc-h3" data-ref="n74"><a class="md-toc-inner" style="cursor: pointer;" href="#%E5%9D%90%E6%A0%87">坐标</a></span><span class="md-toc-item md-toc-h3" data-ref="n94"><a class="md-toc-inner" style="cursor: pointer;" href="#%E4%BE%9D%E8%B5%96">依赖</a></span><span class="md-toc-item md-toc-h3" data-ref="n115"><a class="md-toc-inner" style="cursor: pointer;" href="#%E4%BB%93%E5%BA%93">仓库</a></span><span class="md-toc-item md-toc-h2" data-ref="n152"><a class="md-toc-inner" style="cursor: pointer;" href="#eclipse%E6%95%B4%E5%90%88maven">eclipse整合Maven</a></span><span class="md-toc-item md-toc-h3" data-ref="n153"><a class="md-toc-inner" style="cursor: pointer;" href="#eclipse%E5%85%B3%E8%81%94maven">eclipse关联maven</a></span><span class="md-toc-item md-toc-h3" data-ref="n164"><a class="md-toc-inner" style="cursor: pointer;" href="#%E6%96%B0%E5%BB%BAmaven%E9%A1%B9%E7%9B%AE">新建maven项目</a></span><span class="md-toc-item md-toc-h3" data-ref="n179"><a class="md-toc-inner" style="cursor: pointer;" href="#%E5%85%B6%E4%BB%96%E9%97%AE%E9%A2%98">其他问题</a></span><span class="md-toc-item md-toc-h2" data-ref="n188"><a class="md-toc-inner" style="cursor: pointer;" href="#idea%E6%95%B4%E5%90%88maven">IDEA整合maven</a></span><span class="md-toc-item md-toc-h2" data-ref="n189"><a class="md-toc-inner" style="cursor: pointer;" href="#%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4">常见命令</a></span><span class="md-toc-item md-toc-h3" data-ref="n197"><a class="md-toc-inner" style="cursor: pointer;" href="#%E7%BC%96%E8%AF%91">编译</a></span><span class="md-toc-item md-toc-h3" data-ref="n201"><a class="md-toc-inner" style="cursor: pointer;" href="#%E7%BC%96%E8%AF%91%E6%B5%8B%E8%AF%95">编译测试</a></span><span class="md-toc-item md-toc-h3" data-ref="n205"><a class="md-toc-inner" style="cursor: pointer;" href="#%E6%B8%85%E7%A9%BA">清空</a></span><span class="md-toc-item md-toc-h3" data-ref="n209"><a class="md-toc-inner" style="cursor: pointer;" href="#%E6%B5%8B%E8%AF%95">测试</a></span><span class="md-toc-item md-toc-h3" data-ref="n216"><a class="md-toc-inner" style="cursor: pointer;" href="#%E6%89%93%E5%8C%85">打包</a></span><span class="md-toc-item md-toc-h3" data-ref="n222"><a class="md-toc-inner" style="cursor: pointer;" href="#%E5%AE%89%E8%A3%85">安装</a></span><span class="md-toc-item md-toc-h2" data-ref="n227"><a class="md-toc-inner" style="cursor: pointer;" href="#%E4%BE%9D%E8%B5%96%E4%BD%9C%E7%94%A8%E5%9F%9F">依赖作用域</a></span><span class="md-toc-item md-toc-h2" data-ref="n244"><a class="md-toc-inner" style="cursor: pointer;" href="#maven%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F">Maven生命周期</a></span><span class="md-toc-item md-toc-h2" data-ref="n260"><a class="md-toc-inner" style="cursor: pointer;" href="#maven%E7%9A%84web%E9%A1%B9%E7%9B%AE">maven的web项目</a></span><span class="md-toc-item md-toc-h3" data-ref="n261"><a class="md-toc-inner" style="cursor: pointer;" href="#%E6%96%B0%E5%BB%BAmaven%E7%9A%84web%E9%A1%B9%E7%9B%AE">新建maven的web项目</a></span><span class="md-toc-item md-toc-h3" data-ref="n270"><a class="md-toc-inner" style="cursor: pointer;" href="#web%E9%A1%B9%E7%9B%AE%E6%9C%AC%E5%9C%B0%E5%8F%91%E5%B8%83">web项目本地发布</a></span><span class="md-toc-item md-toc-h2" data-ref="n276"><a class="md-toc-inner" style="cursor: pointer;" href="#maven%E9%AB%98%E7%BA%A7">Maven高级</a></span><span class="md-toc-item md-toc-h3" data-ref="n277"><a class="md-toc-inner" style="cursor: pointer;" href="#properties%E5%8F%82%E6%95%B0%E9%85%8D%E7%BD%AE">Properties参数配置</a></span><span class="md-toc-item md-toc-h4" data-ref="n356"><a class="md-toc-inner" style="cursor: pointer;" href="#maven%E5%86%85%E7%BD%AE%E5%8F%82%E6%95%B0">maven内置参数</a></span><span class="md-toc-item md-toc-h4" data-ref="n362"><a class="md-toc-inner" style="cursor: pointer;" href="#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E6%95%B0">自定义参数</a></span><span class="md-toc-item md-toc-h3" data-ref="n279"><a class="md-toc-inner" style="cursor: pointer;" href="#%E7%BB%A7%E6%89%BF">继承</a></span><span class="md-toc-item md-toc-h3" data-ref="n281"><a class="md-toc-inner" style="cursor: pointer;" href="#%E8%81%9A%E5%90%88">聚合</a></span><span class="md-toc-item md-toc-h3" data-ref="n283"><a class="md-toc-inner" style="cursor: pointer;" href="#web%E9%A1%B9%E7%9B%AE%E8%BF%9C%E7%A8%8B%E5%8F%91%E5%B8%83">web项目远程发布</a></span><span class="md-toc-item md-toc-h2" data-ref="n722"><a class="md-toc-inner" style="cursor: pointer;" href="#nexus%E7%A7%81%E6%9C%8D">nexus私服</a></span></p></div><h1><a name="maven" class="md-header-anchor"></a><span>maven</span></h1><h2><a name="%E5%BC%95%E8%A8%80" class="md-header-anchor"></a><span>引言</span></h2><ol start='' ><li><p><span>目前项目开发中遇到的问题</span></p><blockquote><p><span>① 一个项目就是一个工程，使用package划分模块。</span></p><p><span>② 项目依赖的jar，需要手动复制到lib目录中，且需要程序员自己记忆维护jar的依赖关系，以及版本匹配。</span></p><p><span>③ 不同的java的IDE开发工具的默认web项目的目录结构不一样，多人协同开发的时候，不同开发工具不兼容。(eclipse me idea:webroot webcontent web)</span></p></blockquote></li><li><p><span>简介</span></p><blockquote><p><span>Maven是一个基于Java的自动化构建工具。</span></p><p><span>功能： </span></p><p><span>① 统一jar管理和自动依赖处理。</span></p><p><span>② 支持远程部署tomcat。</span></p><p><span>③ 统一项目的目录结构。(无论使用什么开发工具，目录结构都一致)</span></p><p><span>④ 分模块管理项目，一个模块就是一个工程。多个模块构成一个项目。</span></p></blockquote></li><li><p><span>安装</span></p><blockquote><ol start='' ><li><span>下载</span></li></ol><p><code>https://archive.apache.org/dist/maven/</code></p><ol start='2' ><li><p><span>解压</span></p><p><span>目录结构含义：</span></p><p><span>	</span><span>缺图：</span></p></li><li><p><span>设置本地仓库的目录 </span><strong><span>settings配置文件</span></strong></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 18.5px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">localRepository</span><span class="cm-tag cm-bracket">&gt;</span>D:/work/mavenrep<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">localRepository</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 18px;"></div><div class="CodeMirror-gutters" style="display: none; height: 18px;"></div></div></div></pre><p>&nbsp;</p></li><li><p><span>配置环境</span></p></li></ol><ul><li><span>将maven所在的目录配置到M2_HOME(MAVEN_HOME也行)环境变量中。</span></li></ul><p><img src='assets/1566272756727.png' alt='1566272756727' referrerPolicy='no-referrer' /></p><ul><li><span>将maven的bin目录配置到Path环境变量中。</span></li></ul><p><img src='assets/1566272896363.png' alt='1566272896363' referrerPolicy='no-referrer' /></p><ol start='4' ><li><span>测试是否安装成功</span></li></ol><p><span>命令行执行：</span><code>mvn -v</code></p></blockquote></li></ol><p>&nbsp;</p><h2><a name="%E7%AC%AC%E4%B8%80%E4%B8%AAmaven%E9%A1%B9%E7%9B%AE(maven%E7%BC%96%E8%AF%91)" class="md-header-anchor"></a><span>第一个Maven项目(maven编译)</span></h2><h3><a name="1.-maven%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%BC%96%E5%86%99" class="md-header-anchor"></a><span>1. maven配置文件的编写</span></h3><blockquote><p><span>位置：pom.xml文件</span></p><p><span>文件官网模板地址：</span><code>https://maven.apache.org/pom.html</code></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><span><span>​</span>x</span></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">project</span> <span class="cm-attribute">xmlns</span>=<span class="cm-string">"http://maven.apache.org/POM/4.0.0"</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">xmlns:xsi</span>=<span class="cm-string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">xsi:schemaLocation</span>=<span class="cm-string">"http://maven.apache.org/POM/4.0.0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-string">http://maven.apache.org/xsd/maven-4.0.0.xsd"</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">modelVersion</span><span class="cm-tag cm-bracket">&gt;</span>4.0.0<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">modelVersion</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span>公司名<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span>项目名<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span>版本号<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">project</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 198px;"></div><div class="CodeMirror-gutters" style="display: none; height: 198px;"></div></div></div></pre><p>&nbsp;</p><p><span>作用：用来描述该项目的唯一标记。</span></p><p><span>内容：公司名(groupid)+项目名(artifactid)+版本号(version)</span></p></blockquote><h3><a name="2.-%E7%BA%A6%E5%AE%9A%E7%9A%84%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84" class="md-header-anchor"></a><span>2. 约定的项目结构</span></h3><blockquote><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded md-focus" lang="java"><div class="CodeMirror cm-s-inner CodeMirror-wrap CodeMirror-focused" lang="java"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 114.667px; left: 395.031px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">main</span><span class="cm-operator">/</span><span class="cm-variable">java</span><span class="cm-tab" role="presentation" cm-text="	">   </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-variable">编码java代码</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">main</span><span class="cm-operator">/</span><span class="cm-variable">resources</span><span class="cm-tab" role="presentation" cm-text="	">  </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-variable">编写项目的配置文件：properties</span> <span class="cm-variable">xml</span> <span class="cm-variable">yml等</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">main</span><span class="cm-operator">/</span><span class="cm-variable">webapp</span>(<span class="cm-variable">web项目特有</span>)<span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span> <span class="cm-variable">编写web相关代码：JSP</span> <span class="cm-variable">HTML</span> <span class="cm-variable">css</span> <span class="cm-variable">js</span> <span class="cm-variable">img等。相当于eclipse的webroot</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">main</span><span class="cm-operator">/</span><span class="cm-variable">webapp</span><span class="cm-operator">/</span><span class="cm-variable">WEB</span><span class="cm-operator">-</span><span class="cm-variable">INF</span>(<span class="cm-variable">web项目特有</span>) <span class="cm-variable">存放web项目的web</span>.<span class="cm-variable">xml文件</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">test</span><span class="cm-operator">/</span><span class="cm-variable">java</span><span class="cm-tab" role="presentation" cm-text="	">   </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-variable">编写测试代码</span></span></pre><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">src</span><span class="cm-operator">/</span><span class="cm-variable">test</span><span class="cm-operator">/</span><span class="cm-variable">resources</span><span class="cm-tab" role="presentation" cm-text="	">  </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-variable">编写测试的配置文件。</span></span></pre></div><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">pom</span>.<span class="cm-variable">xml</span><span class="cm-tab" role="presentation" cm-text="	"> </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-variable">maven管理项目的配置信息。</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 134px;"></div><div class="CodeMirror-gutters" style="display: none; height: 134px;"></div></div></div></pre></blockquote><h3><a name="3.-%E5%87%86%E5%A4%87%E4%BB%A3%E7%A0%81" class="md-header-anchor"></a><span>3. 准备代码</span></h3><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="java"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">package</span> <span class="cm-def">com</span>.<span class="cm-variable">baizhi</span>.<span class="cm-variable">service</span>;</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">public</span> <span class="cm-keyword">class</span> <span class="cm-def">UserService</span>{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">public</span> <span class="cm-variable-3">boolean</span> <span class="cm-variable">login</span>(<span class="cm-variable-3">String</span> <span class="cm-variable">username</span>,<span class="cm-variable-3">String</span> <span class="cm-variable">password</span>){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">if</span>(<span class="cm-string">"baizhi"</span>.<span class="cm-variable">equals</span>(<span class="cm-variable">username</span>) <span class="cm-operator">&amp;&amp;</span> <span class="cm-string">"123123"</span>.<span class="cm-variable">equals</span>(<span class="cm-variable">password</span>)){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">return</span> <span class="cm-atom">true</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  }<span class="cm-keyword">else</span> {</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">return</span> <span class="cm-atom">false</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 198px;"></div><div class="CodeMirror-gutters" style="display: none; height: 198px;"></div></div></div></pre><h3><a name="3.-%E6%89%A7%E8%A1%8Cmaven%E5%91%BD%E4%BB%A4" class="md-header-anchor"></a><span>3. 执行maven命令</span></h3><blockquote><p><span>准备：命令进入到项目所在目录，与pom.xml文件同级。</span></p><p><code>mvn compile</code><span> </span></p><p><span>作用：对当前项目的代码进行编译，将编译后的文件放在当前项目的 </span><strong><span>target/classes目录下</span></strong></p><p><code>mvn clean</code></p><p><span>作用：清空当前项目的编译结果。</span></p></blockquote><h2><a name="maven%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5" class="md-header-anchor"></a><span>Maven核心概念</span></h2><h3><a name="pom" class="md-header-anchor"></a><span>POM</span></h3><ul><li><span>概念：Project Object Model 工程对象模型。</span></li><li><span>作用：Maven项目的核心配置文件，maven项目相关的全部信息，都要在这里配置。</span></li></ul><h3><a name="%E5%9D%90%E6%A0%87" class="md-header-anchor"></a><span>坐标</span></h3><blockquote><ol start='' ><li><span>作用：在互联网中用来唯一定位一个maven项目。</span></li><li><span>构成：公司域名倒置+项目名+版本</span></li></ol><ul><li><strong><code>groupid</code></strong><span> - 公司域名倒置</span></li><li><strong><code>artifactid</code></strong><span> - 项目名</span></li><li><strong><code>version</code></strong><span> - 版本号</span></li></ul><ol start='3' ><li><span>书写位置：pom.xml文件中。</span></li><li><span>示例: </span></li></ol><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span>com.baizhiedu<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span>ssm<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span>1.0<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 54px;"></div><div class="CodeMirror-gutters" style="display: none; height: 54px;"></div></div></div></pre></blockquote><h3><a name="%E4%BE%9D%E8%B5%96" class="md-header-anchor"></a><span>依赖</span></h3><blockquote><ol start='' ><li><span>概念：项目开发需要使用的第三方的jar</span></li><li><span>引入方式：</span></li></ol><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">dependencies</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-comment">&lt;!-- 一个dependency就是一个jar的依赖 --&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">dependency</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span>com.baizhiedu<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span>ssm<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span>1.0<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">dependency</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-comment">&lt;!-- junit依赖 --&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">dependency</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span>junit<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span>junit<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span>4.12<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">dependency</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">dependencies</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 257px;"></div><div class="CodeMirror-gutters" style="display: none; height: 257px;"></div></div></div></pre><ol start='3' ><li><span>测试演示：</span></li><li><span>加入junit测试依赖</span></li><li><span>编写测试代码</span></li></ol><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="java"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">package</span> <span class="cm-def">com</span>.<span class="cm-variable">baizhi</span>.<span class="cm-variable">service</span>;</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">import</span> <span class="cm-variable">org</span>.<span class="cm-variable">junit</span>.<span class="cm-variable">Test</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-keyword">public</span> <span class="cm-keyword">class</span> <span class="cm-def">UserServiceTest</span>{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; <span class="cm-meta">@Test</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; <span class="cm-keyword">public</span> <span class="cm-variable-3">void</span> <span class="cm-variable">test1</span>(){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">UserService</span> <span class="cm-variable">us</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">UserService</span>();</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable-3">boolean</span> <span class="cm-variable">login</span> <span class="cm-operator">=</span> <span class="cm-variable">us</span>.<span class="cm-variable">login</span>(<span class="cm-string">"baizhi"</span>,<span class="cm-string">"123123"</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">System</span>.<span class="cm-variable">out</span>.<span class="cm-variable">println</span>(<span class="cm-string">"login is:"</span><span class="cm-operator">+</span><span class="cm-variable">login</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-variable">org</span>.<span class="cm-variable">junit</span>.<span class="cm-variable">Assert</span>.<span class="cm-variable">assertTrue</span>(<span class="cm-variable">login</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> }</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 216px;"></div><div class="CodeMirror-gutters" style="display: none; height: 216px;"></div></div></div></pre><ol start='3' ><li><span>执行测试</span></li></ol><p><span> 命令: </span><code>mvn test</code></p><p>&nbsp;</p></blockquote><h3><a name="%E4%BB%93%E5%BA%93" class="md-header-anchor"></a><span>仓库</span></h3><ol start='' ><li><p><span>仓库作用</span></p><blockquote><p><span>管理maven项目开发需要的内容</span></p><p><span>① maven相关的插件(自带部分插件，也可以引入额外插件)</span></p><p><span>	</span><span>例如：</span><strong><span>${maven安装目录}\org\apache\maven\plugins</span></strong><span> 下面都是插件。</span></p><p><span>② 管理项目开发需要依赖的jar</span></p><p><span>	</span><span>依赖配置和仓库依赖的对应关系：</span></p><p><span>	</span><span>仓库中目录：</span><code>groupId/artifactId/version/artifactId-version</code></p><p><span>③ 管理我们自己开发的项目(jar)</span></p><p><span>	</span><span>如何打包当前项目：</span></p><p><span>		</span><span>a：</span><package><span>jar</span></package></p><p><span>		</span><span>b: 执行命令：mvn install</span></p><p><span>		</span><span>c: maven仓库中就会存在当前项目坐标对应的jar。</span></p><p><span>	</span><span>安装未存在于中央仓库的第三方jar</span></p><p><span>		</span><code>mvn install:install-file -Dfile=D:/ojdbc6-11.2.0.3.jar -DgroupId=com.oracle -DartifactId=ojdbc -Dversion=6.0 -Dpackaging=jar</code></p></blockquote></li><li><p><span>仓库分类</span></p><blockquote><p><span>本地仓库: 存在于开发人员自己的电脑上,当前开发人员提供maven工程资源管理功能</span></p><p><span>中央仓库：存在于互联网上，maven官方提供的，为全球所有开发人员提供maven工程资源管理功能。</span></p><p><span>	</span><span>web管理网站：</span><a href='https://mvnrepository.com' target='_blank' class='url'>https://mvnrepository.com</a></p><p><span>中央仓库镜像：拷贝了一份官方的maven仓库，分担中央仓库的访问压力。</span></p></blockquote></li><li><p><span>阿里maven镜像配置</span></p><ul><li><p><span>打开maven/conf/settings配置文件</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 18.5px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">mirror</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">id</span><span class="cm-tag cm-bracket">&gt;</span>alimaven<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">id</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">name</span><span class="cm-tag cm-bracket">&gt;</span>aliyun maven<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">name</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">url</span><span class="cm-tag cm-bracket">&gt;</span>http://maven.aliyun.com/nexus/content/groups/public/<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">url</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">mirrorOf</span><span class="cm-tag cm-bracket">&gt;</span>central<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">mirrorOf</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">mirror</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 108px;"></div><div class="CodeMirror-gutters" style="display: none; height: 108px;"></div></div></div></pre></li></ul></li><li><p><span>依赖查找规则：</span></p><blockquote><p><span>① 当前项目会先从本地仓库查找依赖的jar。</span></p><p><span>② 如果找不到，就从中央仓库查找。</span></p><p><span>	</span><img src='assets/1566973393964.png' alt='1566973393964' referrerPolicy='no-referrer' /></p></blockquote></li></ol><h2><a name="eclipse%E6%95%B4%E5%90%88maven" class="md-header-anchor"></a><span>eclipse整合Maven</span></h2><h3><a name="eclipse%E5%85%B3%E8%81%94maven" class="md-header-anchor"></a><span>eclipse关联maven</span></h3><blockquote><ol start='' ><li><span>新版本的eclipse自带maven插件，无序安装。</span></li><li><span>修改默认配置文件和本地仓库。</span></li></ol><p><span>① 打开maven插件：windows--preferences--maven</span></p><p><span>② 关联maven：installations--Add--找到maven安装目录</span></p><p><span>③ 关联maven的配置文件：User Settings--Brower</span></p><p><img src='assets/1566975409594.png' alt='1566975409594' referrerPolicy='no-referrer' /></p></blockquote><h3><a name="%E6%96%B0%E5%BB%BAmaven%E9%A1%B9%E7%9B%AE" class="md-header-anchor"></a><span>新建maven项目</span></h3><blockquote><ol start='' ><li><span>创建maven项目</span></li></ol><p><span>new -- project -- maven project -- 选择create simple project下一步。</span></p><p><img src='assets/1566981566043.png' alt='1566981566043' referrerPolicy='no-referrer' /></p><p><span>完成后，自动添加了maven的项目目录结构</span></p><ol start='2' ><li><p><span>修改jdk编码：</span></p><p><span>修改maven项目的pom.xml文件</span></p></li></ol><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre>x</pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span> &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">maven.compiler.source</span><span class="cm-tag cm-bracket">&gt;</span>1.8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">maven.compiler.source</span><span class="cm-tag cm-bracket">&gt;</span> &nbsp; &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span> &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">maven.compiler.target</span><span class="cm-tag cm-bracket">&gt;</span>1.8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">maven.compiler.target</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 75px;"></div><div class="CodeMirror-gutters" style="display: none; height: 75px;"></div></div></div></pre><p>&nbsp;</p></blockquote><h3><a name="%E5%85%B6%E4%BB%96%E9%97%AE%E9%A2%98" class="md-header-anchor"></a><span>其他问题</span></h3><ol start='' ><li><p><span>terminal乱码</span></p><blockquote><p><span>① 设置代码文件的编码格式为UTF-8</span></p><p><span>② win系统命令行--属性--设置使用旧版命令窗口</span></p></blockquote><p>&nbsp;</p></li></ol><h2><a name="idea%E6%95%B4%E5%90%88maven" class="md-header-anchor"></a><span>IDEA整合maven</span></h2><h2><a name="%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4" class="md-header-anchor"></a><span>常见命令</span></h2><blockquote><p><span>须知：</span></p><ol start='' ><li><span>所有命令执行的位置，都是在当前项目下，与pom.xml目录同级。</span></li><li><span>新建一个maven-dao项目。</span></li></ol></blockquote><h3><a name="%E7%BC%96%E8%AF%91" class="md-header-anchor"></a><span>编译</span></h3><blockquote><p><span>命令：</span><code>mvn compile</code></p><p><span>作用：编译java的源代码</span></p></blockquote><h3><a name="%E7%BC%96%E8%AF%91%E6%B5%8B%E8%AF%95" class="md-header-anchor"></a><span>编译测试</span></h3><blockquote><p><span>命令：</span><code>mvn test-compile</code></p><p><span>作用：编译测试test文件夹下的源代码。</span></p></blockquote><h3><a name="%E6%B8%85%E7%A9%BA" class="md-header-anchor"></a><span>清空</span></h3><blockquote><p><span>命令：</span><code>mvn clean</code></p><p><span>作用：清空编译结果，防止对下次编译结果产生影响。(一般没事)</span></p></blockquote><h3><a name="%E6%B5%8B%E8%AF%95" class="md-header-anchor"></a><span>测试</span></h3><blockquote><ol start='' ><li><span>执行测试的命令: </span><code>mvn test</code></li><li><span>作用：执行所有的测试代码。</span></li></ol></blockquote><h3><a name="%E6%89%93%E5%8C%85" class="md-header-anchor"></a><span>打包</span></h3><blockquote><p><span>命令：</span><code>mvn package</code></p><p><span>作用：将当前项目打包。</span></p><p><span>	</span><span>java项目</span><span>	</span><code>&lt;package&gt;jar&lt;/package&gt;</code><span> 将当前项目打包成jar包。</span></p><p><span>	</span><span>web项目</span><span>	</span><code>&lt;package&gt;war&lt;/package&gt;</code><span> 将当前项目打包成war包。</span></p></blockquote><h3><a name="%E5%AE%89%E8%A3%85" class="md-header-anchor"></a><span>安装</span></h3><blockquote><p><span>命令：</span><code>mvn install</code></p><p><span>作用：将当前项目打包好的jar，放在本地仓库。</span></p></blockquote><p>&nbsp;</p><h2><a name="%E4%BE%9D%E8%B5%96%E4%BD%9C%E7%94%A8%E5%9F%9F" class="md-header-anchor"></a><span>依赖作用域</span></h2><blockquote><ol start='' ><li><span>test</span></li></ol><p><span>仅测试代码可用在执行测试的时候可以用。</span></p><p><span>例如：junit包</span></p><ol start='2' ><li><span>provided</span></li></ol><p><span>主程序和测试代码，都可用，但是打包后丢弃。</span></p><p><span>例如：servlet 和jsp 依赖</span></p><ol start='3' ><li><span>compile(默认)</span></li></ol><p><span>全程参与：测试可用，主程序可用，打包后依然存在</span></p><p><span>例如：spring  ojdbc mybatis等等。</span></p></blockquote><h2><a name="maven%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F" class="md-header-anchor"></a><span>Maven生命周期</span></h2><blockquote><p><span>由maven来负责项目从编译到发布整个生命周期。</span></p><p><img src='assets/Maven生命周期-1566989014763.png' alt='Maven生命周期' referrerPolicy='no-referrer' /></p><p><span>生命周期：</span></p><p><span>		</span><span>0. 按照maven的目录结构，编写 </span><strong><span>java jsp css js img</span></strong><span> (maven不管，由程序员自行搞定)</span></p><p><span>		</span><span>1. 清理：将之前已经编译过的文件，清理掉。</span></p><p><span>		</span><span>2. 编译：将java代码---&gt;class文件。</span></p><p><span>		</span><span>3. 测试：一键对所有测试案例执行测试。</span></p><p><span>		</span><span>5. 打包：将web项目打包成war文件，如果是java项目则打包成jar。</span></p><p><span>		</span><span>6. 安装：将项目打包后，安装到maven仓库中，供其他项目使用。</span></p><p><span>		</span><span>7. 部署(远程)：将项目打包后的文件，远程发送给服务器(tomcat),并自动部署在webapps中。</span></p><p><span>特性：</span></p><p><span>	</span><span>mvn生命周期中的每个命令，会自动之前周期之前必要的前置命令。</span></p><p><span>		</span><span>比如：执行发布的时候，会自动将所有代码编译，测试，打包，部署。</span></p></blockquote><p>&nbsp;</p><h2><a name="maven%E7%9A%84web%E9%A1%B9%E7%9B%AE" class="md-header-anchor"></a><span>maven的web项目</span></h2><h3><a name="%E6%96%B0%E5%BB%BAmaven%E7%9A%84web%E9%A1%B9%E7%9B%AE" class="md-header-anchor"></a><span>新建maven的web项目</span></h3><blockquote><ol start='' ><li><span>新建maven project</span></li><li><span>创建webapp目录下的WEB-INF和web.xml文件</span></li></ol><p><span>项目--右键--Java EE tools--generate Deployeement descriptor stub</span></p><p><img src='assets/1566988909237.png' alt='1566988909237' referrerPolicy='no-referrer' /></p></blockquote><h3><a name="web%E9%A1%B9%E7%9B%AE%E6%9C%AC%E5%9C%B0%E5%8F%91%E5%B8%83" class="md-header-anchor"></a><span>web项目本地发布</span></h3><blockquote><p><span>原来怎么发布，现在怎么发布。</span></p></blockquote><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><h2><a name="maven%E9%AB%98%E7%BA%A7" class="md-header-anchor"></a><span>Maven高级</span></h2><h3><a name="properties%E5%8F%82%E6%95%B0%E9%85%8D%E7%BD%AE" class="md-header-anchor"></a><span>Properties参数配置</span></h3><h4><a name="maven%E5%86%85%E7%BD%AE%E5%8F%82%E6%95%B0" class="md-header-anchor"></a><span>maven内置参数</span></h4><blockquote><ol><li><p><span>JDK版本设置</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 18.5px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment">&lt;!-- 指定java源代码的版本号 --&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">maven.compiler.source</span><span class="cm-tag cm-bracket">&gt;</span>1.8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">maven.compiler.source</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment">&lt;!-- 指定编译后class文件的版本号 --&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">maven.compiler.target</span><span class="cm-tag cm-bracket">&gt;</span>1.8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">maven.compiler.target</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment">&lt;!-- 指定使用的javac编译器的版本 --&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">maven.compiler.compilerVersion</span><span class="cm-tag cm-bracket">&gt;</span>1.8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">maven.compiler.compilerVersion</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 144px;"></div><div class="CodeMirror-gutters" style="display: none; height: 144px;"></div></div></div></pre><p><img src='assets/1567051855177.png' alt='1567051855177' referrerPolicy='no-referrer' /></p></li><li><p><span>设置编码格式：</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 18.5px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-comment">&lt;!--自动将maven项目的所有Java代码文件等代码的编码格式设置--&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">project.build.sourceEncoding</span><span class="cm-tag cm-bracket">&gt;</span>UTF-8<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">project.build.sourceEncoding</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">properties</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 73px;"></div><div class="CodeMirror-gutters" style="display: none; height: 73px;"></div></div></div></pre></li></ol><p>&nbsp;</p></blockquote><h4><a name="%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E6%95%B0" class="md-header-anchor"></a><span>自定义参数</span></h4><blockquote><p>&nbsp;</p><p>&nbsp;</p></blockquote><p>&nbsp;</p><p>&nbsp;</p><h3><a name="%E7%BB%A7%E6%89%BF" class="md-header-anchor"></a><span>继承</span></h3><p>&nbsp;</p><h3><a name="%E8%81%9A%E5%90%88" class="md-header-anchor"></a><span>聚合</span></h3><p>&nbsp;</p><h3><a name="web%E9%A1%B9%E7%9B%AE%E8%BF%9C%E7%A8%8B%E5%8F%91%E5%B8%83" class="md-header-anchor"></a><span>web项目远程发布</span></h3><blockquote><ol start='' ><li><span>配置tomcat的访问权限。</span></li></ol><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">&lt;!--添加角色，具有访问tomcat的manager/text路径的权限--&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">role</span> <span class="cm-attribute">rolename</span>=<span class="cm-string">"manager-script"</span><span class="cm-tag cm-bracket">/&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">&lt;!--添加用户，绑定权限--&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">user</span> <span class="cm-attribute">password</span>=<span class="cm-string">"123123"</span> <span class="cm-attribute">username</span>=<span class="cm-string">"admins"</span> <span class="cm-attribute">roles</span>=<span class="cm-string">"manager-script"</span> <span class="cm-tag cm-bracket">/&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 72px;"></div><div class="CodeMirror-gutters" style="display: none; height: 72px;"></div></div></div></pre><p>&nbsp;</p><ol start='2' ><li><span>在maven项目中添加远程发布web项目的插件</span></li></ol><figure><table><thead><tr><th><span>属性(标签)</span></th><th><span>值</span></th><th><span>含义</span></th></tr></thead><tbody><tr><td><span>groupId</span></td><td><span>org.apache.tomcat.maven</span></td><td><span>插件坐标groupid</span></td></tr><tr><td><span>artifactId</span></td><td><span>tomcat7-maven-plugin</span></td><td><span>插件坐标artifactid</span></td></tr><tr><td><span>version</span></td><td><span>2.2</span></td><td><span>插件版本</span></td></tr><tr><td><span>configuration.url</span></td><td><a href='http://127.0.0.1:8080/manager/text' target='_blank' class='url'>http://127.0.0.1:8080/manager/text</a><span>   此处不能使用localhost该插件不支持。</span></td><td><span>远程tomcat部署项目使用的url请求路径。</span></td></tr><tr><td><span>configuration.username</span></td><td><span>admins</span></td><td>&nbsp;</td></tr><tr><td><span>configuration.password</span></td><td><span>123123</span></td><td>&nbsp;</td></tr></tbody></table></figure><p>&nbsp;</p><p><span>示例代码如下：</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="xml"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="xml"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">plugin</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span>org.apache.tomcat.maven<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">groupId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span>tomcat7-maven-plugin<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">artifactId</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span>2.2<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">version</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">configuration</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">url</span><span class="cm-tag cm-bracket">&gt;</span>http://127.0.0.1:8080/manager/text<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">url</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">username</span><span class="cm-tag cm-bracket">&gt;</span>admins<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">username</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-tag cm-bracket">&lt;</span><span class="cm-tag">password</span><span class="cm-tag cm-bracket">&gt;</span>123123<span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">password</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">configuration</span><span class="cm-tag cm-bracket">&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tag cm-bracket">&lt;/</span><span class="cm-tag">plugin</span><span class="cm-tag cm-bracket">&gt;</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 180px;"></div><div class="CodeMirror-gutters" style="display: none; height: 180px;"></div></div></div></pre><p>&nbsp;</p><ol start='3' ><li><span>使用命令</span></li></ol><p><code>mvn tomcat7:run</code><span>: 对当前项目编译，打包，并发送到远程tomcat，同时启动tomcat加载该项目 </span><strong><span>无需事先启动tomcat</span></strong></p><p><code>mvn tomcat7:deploy</code><span>:将当前项目，打包，并发布到正在运行的远程tomcat中。(第1次部署) </span><strong><span>需要事先启动tomcat</span></strong></p><p><code>mvn tomcat7:redeploy</code><span>:将当前项目，打包，并重新发布到正在运行的远程tomcat中。(第n次部署) </span><strong><span>需要事先启动tomcat</span></strong></p><p>&nbsp;</p><ol start='4' ><li><span>停止服务器</span></li></ol><p><span>命令行：</span><strong><span>ctrl+C</span></strong></p></blockquote><p>&nbsp;</p><h2><a name="nexus%E7%A7%81%E6%9C%8D" class="md-header-anchor"></a><span>nexus私服</span></h2><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p></div>
</body>
</html>